import pymysql



class Db():
    def __init__(self):
        self.conn = pymysql.connect(
            user='root',
            password='root',
            host='localhost',
            db='p7kaoshi',
            charset='utf8',
            cursorclass=pymysql.cursors.DictCursor
        )
        self.cursor = self.conn.cursor()

    def insert(self,sql):
        self.cursor.execute(sql)
        self.conn.commit()

    def find_one(self,sql):
        self.cursor.execute(sql)
        res = self.cursor.fetchone()
        return res
    
    def find_all(self,sql):
        self.cursor.execute(sql)
        res = self.cursor.fetchall()
        return res

db = Db()
# # db.insert("insert into users values(2,'123132132','asdasd')")
# res = db.find_all("select * from users")
# print(res)
